def towers(n, start, stop):
    if n == 1:
        print(n, start, stop)
    else:
        middle = 6 - (start + stop)
        towers(n - 1, start , middle)
        print(n, start, stop)
        towers(n - 1, middle, stop)

if __name__ == "__main__":
    n = int(input())
    towers(n, 1, 3)
